import { HostEnum, type GameJson } from "~/utils";
import { getServerCache } from "../plugins/cache";

/** 获取某个游戏信息 */
export default defineEventHandler(async (event): Promise<GameJson> => {
  const { hostName = HostEnum.localhost, gameId } = await readBody(event);
  const { allGameJson = [] } = getServerCache().gameJsonDataSource[hostName];
  return allGameJson?.find((item: GameJson) => item.id == gameId);
});
